home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / tex / lametex_.z / lametex_ / lametex / src / Justify.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-07  |  1.8 KB  |  79 lines

  1. /* Justify.C
  2.  *
  3.  * When the user wants flushright, flushleft, centered, or the normal
  4.  * full justification, this class is used.
  5.  *
  6.  * Copyright 1992 Jonathan Monsarrat. Permission given to freely distribute,
  7.  * edit and use as long as this copyright statement remains intact.
  8.  *
  9.  */
  10.  
  11. #include "Global.h"
  12. #include "Justify.h"
  13. #include "Document.h"
  14. #include <fstream.h>
  15.  
  16. Justify::Justify()
  17. {
  18.    justifytype = Normal;
  19.    postscript_set(-justifytype);
  20. }
  21.  
  22. Justify::Justify(Justify *base)
  23. {
  24.    justifytype = base->justifytype;
  25. }
  26.  
  27. Param *Justify::copy()
  28. {
  29.    return new Justify(this);
  30. }
  31.  
  32. /* What kind of justification will the following text in this environment
  33.  * have? Set the justifytype variable as appropriate.
  34.  */
  35. int Justify::set(int subtype, float, char *)
  36. {
  37.    if(justifytype != subtype) {
  38.       justifytype = subtype;      // Set the internal placeholder for reference
  39.         // Print the postscript command for this.
  40.       postscript_set(subtype);
  41.    }
  42.    return TRUE;
  43. }
  44.  
  45. float Justify::get(int, char *)
  46. {
  47.    return (float)justifytype;
  48. }
  49.  
  50. void Justify::postscript_set(int subtype)
  51. {
  52.    if(subtype>0 && Stack::get(Environment::PDocument,Document::StartPage, ""))
  53.       Global::files->outfile << endl << "NEWPARA ";
  54.    else
  55.       subtype = -subtype;
  56.    switch(subtype) {
  57.    case Center:
  58.       Global::files->outfile << "/justify " << (int)'c' << " def";
  59.       break;
  60.    case FlushLeft:
  61.       Global::files->outfile << "/justify " << (int)'l' << " def";
  62.       break;
  63.    case FlushRight:
  64.       Global::files->outfile << "/justify " << (int)'r' << " def";
  65.       break;
  66.    case Normal:
  67.       Global::files->outfile << "/justify " << (int)'f' << " def";
  68.       break;
  69.    }
  70.    Global::files->outfile << endl;
  71. }
  72.  
  73. void Justify::revert(Param *from)
  74. {
  75.    int subtype = (int)from->get(0,"");
  76.    if(subtype != justifytype)
  77.       postscript_set(justifytype);
  78. }
  79.